import {message} from 'antd';
import request from '@/utils/request';

const userModel = {
  namespace: 'integral',
  state: {
    carList: [],
    integralUsers: []
  },
  effects: {
    *init(_, {call, put}){
      yield put({type: 'getCarList'})
    },
    *getCarList(_, {call, put}){
      const {code, data:{records = []} = {}} = yield call(() => request('/api1/baseFunction/carPageList', {method: 'post', data: {pageNum: 1, pageSize: 9999}}));
      if (code && code === 200){
        yield put({
          type: 'setState',
          payload: {
            carList: [...records]
          }
        })
      }
    }
  },
  reducers: {
    setState(state, {payload}){
      return {
        ...state,
        ...payload
      }
    }
  }
};
export default userModel;
